package com.mgface.zookeeper.zkclient;

import org.I0Itec.zkclient.ZkClient;
import org.apache.zookeeper.data.Stat;

public class CreateNode {
	public static void main(String[] args) {
//		ZkClient client = new ZkClient("127.0.0.1:2181", 10_000, 10_000);
//		client.createEphemeral("/zk/client", "version1.0");
//		Stat stat = new Stat();
//		Object v = client.readData("/zk/client",stat);
//		System.out.println("值:"+v+",stat:"+stat);
		ZkClient client = new ZkClient("127.0.0.1:2181", 10_000, 10_000);
		client.createPersistent("/zk/client", true);
		String newpath = client.createEphemeralSequential("/zk/client/001", "001");
		System.out.println("生成的新节点名称:"+newpath);
		String newpath2 = client.createEphemeralSequential("/zk/client/001", "002");
		System.out.println("生成的新节点名称2:"+newpath2);
		Stat stat = new Stat();
		Object v = client.readData(newpath,stat);
		System.out.println("值:"+v+",stat:"+stat);
	}
}
